package com.zkingsoft.actions.admin;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.constance.Dictionary;
import com.zkingsoft.dao.UtilDao;
import com.zkingsoft.model.Bug;
import com.zkingsoft.model.Task;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.BugFlowService;
import com.zkingsoft.services.BugService;
import com.zkingsoft.services.TaskService;
import com.zkingsoft.services.UsersService;

/**
 * 首页欢迎界面数据查询
 * 
 * @author admin
 *
 */
@Controller
@RequestMapping(value = "welcom")
public class WelcomAction extends BaseController {

	@Resource
	private BugService currentService;
	@Resource
	private BugFlowService bugFlowService;
	@Resource
	private UsersService usersService;
	@Autowired
	private UtilDao utilDao;
	
	@Autowired
	private BugService bugService;
	@Autowired
	private TaskService taskService;
	
	
	/**
	 * 列表显示
	 */
	@RequestMapping(value = "/findMsg")
	public @ResponseBody AjaxResult findMsg() {
		AjaxResult result=new AjaxResult();
		result.setStatus(AjaxResult.STATUS_OK);
		//获取统计信息
		List<Map<Object, Object>> rows = utilDao.selectUserStatus(getMe().getId());
		result.putInMap("nums", rows);
		//获取最新的bug
		PaginationVO page=	new PaginationVO();
		page.setLimit(5);
		page.setSort("createTime");
		page.setOrder("desc");
		Bug bug =new Bug();
		bug.setUserId(getMe().getId());
		bug.setStatus(Dictionary.BUG_STATUS_VAITE);
		result.putInMap("bugs", bugService.findInPage(bug, page));
		//获取最新的未开始任务
		Task task=new Task();
		task.setStatus(Dictionary.TASK_STATUS_NO_START);
		task.setUserId(getMe().getId());
		result.putInMap("task", taskService.findInPage(task, page));
		return result;
	}

}